#ifndef _DSL_BUTTON_H_
#define _DSL_BUTTON_H_

#include <stdint.h>
#include "driver/gpio.h"

#define PAGE_SIZE 1
#define BUTTON_NUM 1

#define DSL_BUTTON_EVENT_HOLD 0x01
#define DSL_BUTTON_EVENT_PRESSDOWN 0x02
#define DSL_BUTTON_EVENT_PRESSUP 0x04

#define DSL_BUTTON_EVENT_CLICK 0x08
#define DSL_BUTTON_EVENT_DBCLICK 0x10
#define DSL_BUTTON_EVENT_LONGPRESS 0x20
#define DSL_BUTTON_EVENT_REPEAT 0x40

#define DSL_BUTTON_SIZE 5
typedef enum {
    BUTTON_TYPE_OK,
    BUTTON_TYPE_UP,
    BUTTON_TYPE_DOWN,
    BUTTON_TYPE_LEFT,
    BUTTON_TYPE_RIGHT,
} button_type_t;

typedef struct {
    uint8_t type;
    uint8_t gpio_num;
} dsl_button_t;

typedef enum {
    DSL_BUTTON_STATUS_UNPRESS,
    DSL_BUTTON_STATUS_PRESS,
} dsl_button_status_t;

typedef void (* dsl_button_cb_t)(const uint8_t event);

void dsl_button_init(void);
uint8_t dsl_button_check(button_type_t button_type, uint8_t flag);
dsl_button_status_t dsl_button_get_status(uint8_t index);
void dsl_button_register(dsl_button_t dsl_button);
void dsl_button_tick(void);

#endif